package com.rn.ddd.interfaces.assembler;

import com.rn.ddd.domain.order.entity.OrderDO;
import com.rn.ddd.infrastructure.base.AssemblerFactory;
import com.rn.ddd.interfaces.dto.OrderCreateQuery;
import org.apache.tomcat.jni.Time;

/**
 * 订单装配器
 *
 * @author 然诺
 * @date 2022/3/26
 */
public class OrderAssembler {

    private static final AssemblerFactory FACTORY = new AssemblerFactory();

    public static OrderDO toEntity(OrderCreateQuery createQuery) {
        if (createQuery == null) {
            return null;
        }
        return FACTORY.convert((source, target) -> {
            target.setOrderName(source.getOrderName());
            target.setPlaceTime(Time.now());
        }, createQuery, OrderDO.class);
    }

}
